<?
include_once('top.inc');
?>
<h2>Управление меню</h2>
<table>
    <tr>
        <td width="300">
        <?php
            $menus=  mysql_query('select * from pages where menu="main" or menu="bottom" or menu="middle" order by id');
            $men['main']=array();
            $men['bottom']=array();
            $men['middle']=array();
            while ($m=  mysql_fetch_assoc($menus)){
                array_push($men[$m['menu']], '<div><a href="/ADM/edit/'.$m['id'].'/?vid=menu">'.$m['title'].'</a></div>');                
            }         
            echo '<b>Верхнее</b>';
            foreach ($men['main'] as $v){
                echo $v;
            }
            echo '<b>Нижнее</b>';
            foreach ($men['bottom'] as $v){
                echo $v;
            }
            echo '<b>Средние банеры</b>';
            foreach ($men['middle'] as $v){
                echo $v;
            }
        ?>            
        </td>
        <td>
            <form action="<? echo $info['url']; ?>" method="post" enctype="multipart/form-data">
    <table width="100%">
        <tr><td>
    <strong>Название:</strong><br />
    <input name="title" type="text" value="<? echo $info['title']; ?>" class="long" /><br />
                <?
                if ($info['menu']=='bottom' ||$info['menu']=='middle'){
                ?>
    <textarea name="short_desc" style="width:250px;"><?=$info['short_desc']?></textarea>
                <?}?>
                <?
                if ($info['menu']=='middle'){
                ?><br/>
    Ссылка на материал<br/>
    <textarea name="parent" style="width:250px;"><?=$info['parent']?></textarea>
                <?}?>
          <?
               if ($info['menu']!='middle') {
                ?><br/>
    Ссылка на материал<br/>
    <textarea name="parent" style="width:250px;"><?=$info['name']?></textarea>
                <?}?>
    
    
    
            </td><td>
                <?
                if ($info['menu']=='main'){
                    ?>
                
<strong>Изображение</strong>(154x116)<br />
            <div style="height:120px; position:relative; float:left; padding:0px;margin-top:0px; margin-right: 0px; width:160px; text-align: center; border:1px solid #cccccc;">
                <?
                }elseif ($info['menu']=='bottom'){
                    ?>
                
<strong>Изображение</strong>(222x112)<br />
            <div style="height:115px; position:relative; float:left; padding:0px;margin-top:0px; margin-right: 0px; width:222px; text-align: center; border:1px solid #cccccc;">
                    <?
                }else{
                    ?>
                
<strong>Изображение</strong>(99x110)<br />
            <div style="height:115px; position:relative; float:left; padding:0px;margin-top:0px; margin-right: 0px; width:99px; text-align: center; border:1px solid #cccccc;">
                    <?
                }
                ?>
                <script type="text/javascript">
                  function ready(file){
                      jQuery("#image").html("<img src='/images/menu/<?=$info['name']?>.png' height='110' />");
                  }
                </script>
                <?
                    if (file_exists(LocalDir.'/images/menu/'.$info['name'].'.png'))
                        $img='<img src="/images/menu/'.$info['name'].'.png" />';
                    else
                        $img='<img src="/images/no-logo.jpg"  width="99" />';
                ?>
                <span id="image" ><?=$img?></span>
                <div style="position:absolute; bottom: 5px; right: 5px;">
                    <span id="loader" ></span></div>
                <script type="text/javascript">
                    var flashvars = {
                            send_to: "/7ert54/process_files.php?menu=<?=$info['name']?>",
                            endFunction: "ready",
                            file_desc:"*.png",
                            file_ext:"*.png;"
                    };
                    var params = {
                            allowscriptaccess: "always",
                            allowFullScreen: "false",
                            wmode:'transparent',
                            name:"uploader"
                    };
                    var attributes = {
                            id: "uploader",
                            name:"uploader"
                    };
                    swfobject.embedSWF("/swf/upl.swf", "loader", "49px", "49px", "9.0.0", false, flashvars, params, attributes);
                    
                </script>
                
            </div> 
            </td>
        </tr>
    </table>
            <input type="submit" value="Сохранить">
            </form>
        </td>
    </tr>
</table>